package cn.com.zpark.servlet_response;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * 设置响应头相关的方法
 */
@WebServlet("/rd3.jsp")
public class ResponseDemo03 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        // 解决响应中文乱码的问题
        response.setContentType("text/html;charset=utf-8");

        response.addHeader("name", "zhangsan");
        response.setHeader("DC", "大锤");

        PrintWriter writer = response.getWriter();
        writer.write("<h1>欢迎学习javaweb的响应对象</h1>");

    }
}
